*=============================================================================*
* Project title: The Causal Effects of R&D Grants
* Created by: Pietro Santoleri
*=============================================================================*

// Clear Memory
clear all


// Set options 
*=============================================================================*

// Download user-written packages (0 for no; 1 for yes)
global downloads 0

// Run main analysis (0 for no; 1 for yes)
global run_analysis 1

// Run analysis in appendix (0 for no; 1 for yes)
global run_appendix 1



// Use included packages
*=============================================================================*

cap adopath - PERSONAL
cap adopath - PLUS
cap adopath - SITE
cap adopath - OLDPLACE
adopath + "stata_packages"
net set ado "stata_packages"

// Download packages 
if $downloads == 1 {
	// Install  Packages
	ssc install blindschemes, replace	
	ssc install coefplot, replace
	ssc install erepost, replace
	ssc install estout, replace	
	ssc install ftools, replace
	ssc install grstyle, replace	
	ssc install ppmlhdfe, replace
	ssc install reghdfe, replace
	net install rdlocrand, from("https://raw.githubusercontent.com/rdpackages/rdlocrand/master/stata") replace
	ssc install rdrobust, replace
	ssc install stddiff, replace
	ssc install tuples, replace
	ssc install winsor2, replace

}


// Set your file paths, These are relative to where the project file is saved. 
*=============================================================================*

global data_path "data/data_for_analysis"
global raw_data_path "data/raw_data" 
global temp_path "temp" 

global script_path "scripts" 
global output "output" 
global appendix "output/appendix" 
global log_path "scripts/logs" 

global restricted_data_raw "restricted_raw_data" 
global restricted_data_analysis "restricted_data_for_analysis"

// Version of stata
version 16

// Specify Screen Width for log files
set linesize 255

// Set font type
graph set window fontface "Roboto"

// Set Graph Scheme
graph set window fontface default
set scheme plotplainblind

// Allow the screen to move without having to click more
set more off

// Drop everything in mata
matrix drop _all

// Run do files
*=============================================================================*


// Run analysis
if $run_analysis == 1 {
	
	do $script_path/Table_1.do

	do $script_path/Table_2.do

	do $script_path/Table_3.do

	do $script_path/Table_4.do

	do $script_path/Table_5.do

	do $script_path/Table_6.do

	do $script_path/Table_7.do

	do $script_path/Figure_1.do

}

// Run analysis in appendix
if $run_appendix == 1 {
	
	do $script_path/appendix.do

}






